package com.jmc.calls;


import java.io.Serializable;
import java.sql.SQLException;
import java.sql.Timestamp;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400Text;
import com.ibm.as400.access.CommandCall;
import com.ibm.as400.access.ProgramCall;
import com.ibm.as400.access.ProgramParameter;

public class TestProgramCallCHKOBJ implements Serializable{

	public static void main(String[] args) throws SQLException{
		System.out.println("Inicio: " + new Timestamp(System.currentTimeMillis()));
		runPG();
		System.out.println("Fin: " + new Timestamp(System.currentTimeMillis()));		
	}
	public static void runPG(){
		// Call programs on system "Hal"
		AS400 as400 = new AS400("www.transfurlong.com.ar", "qsecofer", "c2259");
		ProgramCall pgm = new ProgramCall( as400 );
		try
		{
		//Agrego la Libreria de Datos
		CommandCall cmd = new CommandCall( as400 );
		cmd.run("CHKOBJ OBJ(TRFFILLIB/PD000) OBJTYPE(*FILE)");  

		// Show the messages (returned whether or not there was an error)
		AS400Message[] messagelistCommand = cmd.getMessageList();
		for (int i=0; i < messagelistCommand.length; i++)
		{
		// show each message
		System.out.println(messagelistCommand[i].getText() );
		System.out.println("Id:  " + messagelistCommand[i].getID() );
		}
			
		as400.disconnectAllServices();
		}catch(Exception e){
			e.printStackTrace();
		}
			
	}
}
